<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  
  <button id="get">GET</button>
  <button id="post">POST</button>
  <button id="Delete">DELETE</button>

  <script src="https://cdn.staticfile.org/jquery/1.10.0/jquery.js"></script>
  <script type="text/javascript">
    $(function() {
      var get = $('#get');
      var post = $('#post');
      var btnDelete = $('#Delete');

      get.on('click', () => {
        $.ajax({
          type: 'get',
          url: 'http://127.0.0.1:3000/api/get',
          data: {name: 'zs', age: 18},
          success: function(res) {
            console.log(res);
          }
        })
      })

      post.on('click', function() {
        $.ajax({
          type: 'post',
          url: 'http://127.0.0.1:3000/api/post',
          data: {bookname: '水浒传', age: 88},
          success: function(res) {
            console.log(res);
          }
        })
      })

      btnDelete.on('click', () => {
        $.ajax({
          type: 'delete',
          url: 'http://127.0.0.1:3000/api/delete',
          success: function(res) {
            console.log(res);
          }
        })
      })
    })
  </script>
</body>
</html>